/*     */ package com.zimbra.cs.util;
/*     */ 
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.memcached.MemcachedConnector;
/*     */ import java.io.File;
/*     */ import net.sf.ehcache.CacheManager;
/*     */ import net.sf.ehcache.config.CacheConfiguration;
/*     */ import net.sf.ehcache.config.Configuration;
/*     */ import net.sf.ehcache.config.DiskStoreConfiguration;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class EhcacheManager
/*     */ {
/*  41 */   private static final EhcacheManager SINGLETON = new EhcacheManager();
/*     */   public static final String IMAP_ACTIVE_SESSION_CACHE = "imap-active-session-cache";
/*     */   public static final String IMAP_INACTIVE_SESSION_CACHE = "imap-inactive-session-cache";
/*     */   public static final String SYNC_STATE_ITEM_CACHE = "sync-state-item-cache";
/*     */   
/*     */   private EhcacheManager()
/*     */   {
/*  48 */     Configuration conf = new Configuration();
/*  49 */     DiskStoreConfiguration disk = new DiskStoreConfiguration();
/*  50 */     disk.setPath(LC.zimbra_home.value() + File.separator + "data" + File.separator + "mailboxd");
/*  51 */     conf.addDiskStore(disk);
/*  52 */     conf.addCache(createImapActiveSessionCache());
/*  53 */     if (MemcachedConnector.isConnected()) {
/*  54 */       ZimbraLog.imap.info("Using Memcached for inactive session cache");
/*     */     } else {
/*  56 */       conf.addCache(createImapInactiveSessionCache());
/*  57 */       conf.addCache(createSyncStateItemCache());
/*     */     }
/*  59 */     conf.setUpdateCheck(false);
/*  60 */     CacheManager.create(conf);
/*     */   }
/*     */   
/*     */   public static EhcacheManager getInstance() {
/*  64 */     return SINGLETON;
/*     */   }
/*     */   
/*     */   public void startup() {}
/*     */   
/*     */   private CacheConfiguration createImapActiveSessionCache()
/*     */   {
/*  71 */     CacheConfiguration conf = new CacheConfiguration();
/*  72 */     conf.setName("imap-active-session-cache");
/*  73 */     conf.setOverflowToDisk(true);
/*  74 */     conf.setDiskPersistent(false);
/*  75 */     conf.setMaxElementsInMemory(1);
/*  76 */     conf.setMaxElementsOnDisk(0);
/*  77 */     return conf;
/*     */   }
/*     */   
/*     */   private CacheConfiguration createImapInactiveSessionCache() {
/*  81 */     CacheConfiguration conf = new CacheConfiguration();
/*  82 */     conf.setName("imap-inactive-session-cache");
/*  83 */     conf.setOverflowToDisk(true);
/*  84 */     conf.setDiskPersistent(true);
/*  85 */     conf.setMaxElementsInMemory(1);
/*  86 */     conf.setMaxElementsOnDisk(LC.imap_inactive_session_cache_size.intValue());
/*  87 */     return conf;
/*     */   }
/*     */   
/*     */   private CacheConfiguration createSyncStateItemCache() {
/*  91 */     CacheConfiguration conf = new CacheConfiguration();
/*  92 */     conf.setName("sync-state-item-cache");
/*  93 */     conf.setOverflowToDisk(true);
/*  94 */     conf.setDiskPersistent(true);
/*  95 */     conf.setMaxBytesLocalHeap(LC.zimbra_activesync_syncstate_item_cache_heap_size.value());
/*  96 */     conf.setMaxElementsOnDisk(0);
/*  97 */     conf.setTimeToLiveSeconds(LC.zimbra_activesync_metadata_cache_expiration.intValue());
/*  98 */     return conf;
/*     */   }
/*     */   
/*     */   public void shutdown() {
/* 102 */     CacheManager.getInstance().shutdown();
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/util/EhcacheManager.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */